Optimal. Leaf size=245 \[ -\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {b \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a-\sqrt {-b^2}}\right ) (a+b \tan (c+d x))^{1+n}}{2 \sqrt {-b^2} \left (a-\sqrt {-b^2}\right ) d (1+n)}+\frac {b \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a+\sqrt {-b^2}}\right ) (a+b \tan (c+d x))^{1+n}}{2 \sqrt {-b^2} \left (a+\sqrt {-b^2}\right ) d (1+n)}-\frac {b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right ) (a+b \tan (c+d x))^{1+n}}{a^2 d (1+n)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.32, antiderivative size = 245, normalized size of antiderivative = 1.00, number of steps
used = 10, number of rules used = 8, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.381, Rules used = {3650, 3734,
12, 3566, 726, 70, 3715, 67} \begin {gather*} -\frac {b n (a+b \tan (c+d x))^{n+1} \, _2F_1\left (1,n+1;n+2;\frac {b \tan (c+d x)}{a}+1\right )}{a^2 d (n+1)}-\frac {b (a+b \tan (c+d x))^{n+1} \, _2F_1\left (1,n+1;n+2;\frac {a+b \tan (c+d x)}{a-\sqrt {-b^2}}\right )}{2 \sqrt {-b^2} d (n+1) \left (a-\sqrt {-b^2}\right )}+\frac {b (a+b \tan (c+d x))^{n+1} \, _2F_1\left (1,n+1;n+2;\frac {a+b \tan (c+d x)}{a+\sqrt {-b^2}}\right )}{2 \sqrt {-b^2} d (n+1) \left (a+\sqrt {-b^2}\right )}-\frac {\cot (c+d x) (a+b \tan (c+d x))^{n+1}}{a d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 67
Rule 70
Rule 726
Rule 3566
Rule 3650
Rule 3715
Rule 3734
Rubi steps
\begin {align*} \int \cot ^2(c+d x) (a+b \tan (c+d x))^n \, dx &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {\int \cot (c+d x) (a+b \tan (c+d x))^n \left (-b n+a \tan (c+d x)-b n \tan ^2(c+d x)\right ) \, dx}{a}\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {\int a (a+b \tan (c+d x))^n \, dx}{a}+\frac {(b n) \int \cot (c+d x) (a+b \tan (c+d x))^n \left (1+\tan ^2(c+d x)\right ) \, dx}{a}\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}+\frac {(b n) \text {Subst}\left (\int \frac {(a+b x)^n}{x} \, dx,x,\tan (c+d x)\right )}{a d}-\int (a+b \tan (c+d x))^n \, dx\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right ) (a+b \tan (c+d x))^{1+n}}{a^2 d (1+n)}-\frac {b \text {Subst}\left (\int \frac {(a+x)^n}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{d}\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right ) (a+b \tan (c+d x))^{1+n}}{a^2 d (1+n)}-\frac {b \text {Subst}\left (\int \left (\frac {\sqrt {-b^2} (a+x)^n}{2 b^2 \left (\sqrt {-b^2}-x\right )}+\frac {\sqrt {-b^2} (a+x)^n}{2 b^2 \left (\sqrt {-b^2}+x\right )}\right ) \, dx,x,b \tan (c+d x)\right )}{d}\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right ) (a+b \tan (c+d x))^{1+n}}{a^2 d (1+n)}+\frac {b \text {Subst}\left (\int \frac {(a+x)^n}{\sqrt {-b^2}-x} \, dx,x,b \tan (c+d x)\right )}{2 \sqrt {-b^2} d}+\frac {b \text {Subst}\left (\int \frac {(a+x)^n}{\sqrt {-b^2}+x} \, dx,x,b \tan (c+d x)\right )}{2 \sqrt {-b^2} d}\\ &=-\frac {\cot (c+d x) (a+b \tan (c+d x))^{1+n}}{a d}-\frac {b \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a-\sqrt {-b^2}}\right ) (a+b \tan (c+d x))^{1+n}}{2 \sqrt {-b^2} \left (a-\sqrt {-b^2}\right ) d (1+n)}+\frac {b \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a+\sqrt {-b^2}}\right ) (a+b \tan (c+d x))^{1+n}}{2 \sqrt {-b^2} \left (a+\sqrt {-b^2}\right ) d (1+n)}-\frac {b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right ) (a+b \tan (c+d x))^{1+n}}{a^2 d (1+n)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 0.85, size = 190, normalized size = 0.78 \begin {gather*} -\frac {(b+a \cot (c+d x)) \left (a^2 (-i a+b) \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a-i b}\right )+(a-i b) \left (i a^2 \, _2F_1\left (1,1+n;2+n;\frac {a+b \tan (c+d x)}{a+i b}\right )+2 (a+i b) \left (a (1+n) \cot (c+d x)+b n \, _2F_1\left (1,1+n;2+n;1+\frac {b \tan (c+d x)}{a}\right )\right )\right )\right ) \tan (c+d x) (a+b \tan (c+d x))^n}{2 a^2 (a-i b) (a+i b) d (1+n)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.29, size = 0, normalized size = 0.00 \[\int \left (\cot ^{2}\left (d x +c \right )\right ) \left (a +b \tan \left (d x +c \right )\right )^{n}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (a + b \tan {\left (c + d x \right )}\right )^{n} \cot ^{2}{\left (c + d x \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.00 \begin {gather*} \int {\mathrm {cot}\left (c+d\,x\right )}^2\,{\left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}^n \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________